The present invention relates to a method and to an apparatus for optically detecting the dimensions of an object in a chamber that is subjected to heavy soiling, wherein a light beam passes through windows of the chamber and the influence of the object on the light beam is detected. Generally, a light beam focused at the location of the object is periodically deflected in the direction of the dimension to be detected and a conclusion is drawn as to the dimension of the object from the duration for which the light beam is interrupted by the object. It is now clear that a precise measurement requires as unimpeded as possible a passage of the light beam through the windows of the chamber in which the object is disposed. However, this is no longer the case if the windows are highly soiled or even corroded. This is the case, in particular, in systems for extruding and subsequently vulcanizing certain products, for example, cables or wires that are encased in an insulation of cross-linkable plastics or rubber. In this process there is a particularly distinct danger of the windows becoming soiled by condensate and diverse residues, particularly during the vulcanization of rubber during which certain additives are separated. At the relatively high treatment temperatures in a range of 250.degree. C., these impurities may actually be burnt in. Soiling may occur, in particular, also during the so-called flooding of the vulcanization tube before the vulcanization line is opened, that is, at the end of a production process. The disadvantageous consequences of condensate and soiling and the gradual corrosion of the interior faces of the windows have in the past been counteracted by heating the windows and flushing them with hot gases or superheated steam. Moreover, care has been taken that flooding always took place only to a level that lay below the windows which, however, resulted in a loss of finished product. In any case, it is unavoidable for the windows to have to be exchanged at relatively short intervals.